<template>
    <SelectEquip v-if="fasle" @confirm="selectConfirm" @cancel="selectEquipVisible = false"></SelectEquip>
    <div class="e-form" v-else>
        <div class="tabs" v-if="Object.keys(formData).length != 0">
             <el-tabs tab-position="left" v-model="tabsName" @tab-click="onChangeTab">
                 <!-- 基本信息 -->
                <el-tab-pane label="基本信息" name="baseInfo" :disabled="clickTabFlag"></el-tab-pane>
                <el-tab-pane label="维修保养记录" name="maintenanceRecords" :disabled="clickTabFlag"></el-tab-pane>
                <!-- 因需求变更需去掉以下模块，现注释
                <el-tab-pane label="设备参数" name="equipInitparam" :disabled="clickTabFlag"></el-tab-pane>
                <el-tab-pane label="技改登记" name="transformationRegist" :disabled="clickTabFlag"></el-tab-pane>
                <el-tab-pane label="运行记录" name="operationRecord" :disabled="clickTabFlag"></el-tab-pane>
                <el-tab-pane label="检测记录" name="testRecord" :disabled="clickTabFlag"></el-tab-pane>
                <el-tab-pane label="事故记录" name="accidentRecord" :disabled="clickTabFlag"></el-tab-pane>
                -->
                <div>
                    <div id="baseInfoCon">
                        <div class="tabs-title" id="baseInfo">基本信息</div>
                        <div style="width: 100%" class="form">
                            <el-form ref="form" :model="formData.facilityInitialize" label-width="200px">
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="设备名称：">
                                            <el-input v-model="formData.facilityInitialize.equipmentName"  readonly>
                                                <i slot="suffix" class="el-input__icon el-icon-document-copy" ></i>
                                            </el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="所属机构：">
                                            <span>{{ formData.facilityInitialize.orgName }}</span>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="原始编号：">
                                            <el-input v-model="formData.facilityInitialize.originalNum"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="使用单位：">
                                            <el-input v-model="formData.facilityInitialize.useOrg"  readonly>
                                                <i slot="suffix" class="el-input__icon el-icon-document-copy" ></i>
                                            </el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="设备类别：">
                                            <span>{{ formData.facilityInitialize.equipmentType }}</span>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="规格型号：">
                                            <el-input v-model="formData.facilityInitialize.specificationModel"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="设备属性：">
                                            <span>{{ formData.facilityInitialize.equipmentAttribute }}</span>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="计量单位：">
                                            <span>{{ formData.facilityInitialize.meteringUnit }}</span>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="设备原值（元）：">
                                            <el-input v-model="formData.facilityInitialize.equipmentOriginal"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="设备净值（元）：">
                                            <el-input v-model="formData.facilityInitialize.equipmentCompletely"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="购置日期：">
                                            <el-date-picker
                                                v-model="formData.facilityInitialize.purchaseTime"
                                                type="date"
                                                placeholder="选择日期"
                                                value-format="yyyy-MM-dd"
                                                format="yyyy 年 MM 月 dd 日"
                                                :clearable="false"
                                            >
                                            </el-date-picker>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="验收日期：">
                                            <el-date-picker
                                                v-model="formData.facilityInitialize.checkDate"
                                                type="date"
                                                placeholder="选择日期"
                                                value-format="yyyy-MM-dd"
                                                format="yyyy 年 MM 月 dd 日"
                                                :clearable="false"
                                            >
                                            </el-date-picker>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="验收地点：">
                                            <el-input v-model="formData.facilityInitialize.checkPlace"></el-input>
                                        </el-form-item>
                                    </el-col>
                                <el-col :span="12">
                                        <el-form-item label="生产厂商：">
                                            <el-input v-model="formData.facilityInitialize.manufacturer"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                <el-col :span="12">
                                        <el-form-item label="出厂日期：">
                                            <el-date-picker
                                                v-model="formData.facilityInitialize.productionTime"
                                                type="date"
                                                placeholder="选择日期"
                                                value-format="yyyy-MM-dd"
                                                format="yyyy 年 MM 月 dd 日"
                                                :clearable="false"
                                            >
                                            </el-date-picker>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="出厂编号：">
                                            <el-input v-model="formData.facilityInitialize.productionNum"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="规定使用年限：">
                                            <el-input v-model="formData.facilityInitialize.stipulateYear"></el-input>
                                        </el-form-item>
                                    </el-col>
                                <el-col :span="12">
                                        <el-form-item label="使用年限：">
                                            <el-input v-model="formData.facilityInitialize.useYear"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="累计使用数：">
                                            <el-input v-model="formData.facilityInitialize.cumulativeNum"></el-input>
                                        </el-form-item>
                                    </el-col>
                                <el-col :span="12">
                                        <el-form-item label="车牌编号：">
                                            <el-input v-model="formData.facilityInitialize.vehicleNum"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="设备状况：">
                                            <el-select
                                                v-model="formData.facilityInitialize.equipmentCondition"
                                                placeholder="请选择"
                                            >
                                                 <el-option
                                                    v-for="(
                                                        item,index
                                                    ) in equipCondition"
                                                    :key="index"
                                                    :label="item.label"
                                                    :value="item.value"
                                                >
                                                </el-option>
                                            </el-select>
                                        </el-form-item>
                                    </el-col>
                                <el-col :span="12">
                                        <el-form-item label="设备状态：">
                                            <el-select
                                                v-model="formData.facilityInitialize.equipmentStatus"
                                                placeholder="请选择"
                                            >
                                                <el-option
                                                    v-for="(
                                                        item
                                                    ) in equipStatus"
                                                    :key="item.value"
                                                    :label="item.label"
                                                    :value="item.value"
                                                >
                                                </el-option>
                                            </el-select>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="操作手：">
                                            <el-input v-model="formData.facilityInitialize.operation"  readonly>
                                                <i slot="suffix" class="el-input__icon el-icon-document-copy" ></i>
                                            </el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="累计折旧（元）：">
                                            <el-input v-model="formData.facilityInitialize.accumulativeDepreciation"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                            </el-form>
                        </div>
                    </div>

                    <!-- <div id="equipInitparamCon">
                        <div class="tabs-title" id="equipInitparam">设备参数</div>
                        <div class="e-table">
                            <div class="top">
                                <div class="left">
                                    <el-button size="mini" class="btn-blue" @click="smmary">汇总</el-button>
                                    <el-button size="mini" class="btn-blue" @click="addPlanInfo('facilityParameterList')">新增</el-button>
                                    <el-button size="mini"  @click="deletePlanList('facilityParameterList')">删除</el-button>
                                </div>
                            </div>
                            <el-table
                                ref="planTable"
                                :data="formData.facilityParameterList"
                                border
                                style="width: 100%"
                                @cell-mouse-enter="cellMouseEnter"
                                @cell-mouse-leave="cellMouseLeave"
                                :cell-class-name="cellClsNm"
                                @selection-change="planTableSelect($event,'facilityParameterList')"
                            >
                                <el-table-column type="selection" width="55" align="center">
                                </el-table-column>
                                <el-table-column
                                    prop="parameterName"
                                    label="参数名称"
                                    align="center"
                                    width="300"
                                >
                                    <template slot-scope="{ row   }">
                                        <el-input v-model="row.parameterName" clearable></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="parameterValue"
                                    label="具体参数"
                                    align="center"
                                >
                                    <template slot-scope="{ row   }">
                                        <el-input v-model="row.parameterValue" clearable></el-input>
                                    </template>
                                </el-table-column>
                            </el-table>
                        </div>
                    </div> -->

                    <!-- <div id="transformationRegistCon">
                        <div class="tabs-title" id="transformationRegist">技改登记</div>
                        <div class="e-table">
                            <div class="top">
                                <div class="left">
                                    <el-button size="mini" class="btn-blue" @click="smmary">汇总</el-button>
                                    <el-button size="mini" class="btn-blue" @click="addPlanInfo('technicallyRegistrations')">新增</el-button>
                                    <el-button size="mini"  @click="deletePlanList('technicallyRegistrations')">删除</el-button>
                                </div>
                            </div>
                            <el-table
                                ref="planTable"
                                :data="formData.technicallyRegistrations"
                                border
                                style="width: 100%"
                                @cell-mouse-enter="cellMouseEnter"
                                @cell-mouse-leave="cellMouseLeave"
                                :cell-class-name="cellClsNm"
                                @selection-change="planTableSelect($event,'technicallyRegistrations')"
                            >
                                <el-table-column type="selection" width="55" align="center">
                                </el-table-column>
                                <el-table-column
                                    prop="technicallyOrg"
                                    label="技改单位"
                                    align="center"
                                >
                                    <template slot-scope="{ row   }">
                                        <el-input v-model="row.technicallyOrg" clearable></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="equipmentPrice"
                                    label="设备费（元）"
                                    width="200"
                                    align="center"
                                >
                                    <template slot-scope="{ row   }">
                                        <el-input v-model="row.equipmentPrice" clearable></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="artificialCost"
                                    label="人工费（元）"
                                    width="200"
                                    align="center"
                                >
                                    <template slot-scope="{ row   }">
                                        <el-input v-model="row.artificialCost" clearable></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="materialPrice"
                                    label="材料费（元）"
                                    width="200"
                                    align="center"
                                >
                                    <template slot-scope="{ row   }">
                                        <el-input v-model="row.materialPrice" clearable></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="technicallyPrice"
                                    label="技改费（元）"
                                    width="200"
                                    align="center"
                                >
                                    <template slot-scope="{ row   }">
                                        <el-input v-model="row.technicallyPrice" clearable></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="technicallyIncreasePrice"
                                    label="技改后增值（元）"
                                    width="200"
                                    align="center"
                                >
                                    <template slot-scope="{ row   }">
                                        <el-input v-model="row.technicallyIncreasePrice" clearable></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="recordDate"
                                    label="登记日期"
                                    width="250"
                                    align="center"
                                >
                                    <template slot-scope="{ row }">
                                        <el-date-picker
                                            v-model="row.recordDate"
                                            type="date"
                                            placeholder="选择日期"
                                            value-format="yyyy-MM-dd"
                                            format="yyyy 年 MM 月 dd 日"
                                            :clearable="false"
                                        >
                                        </el-date-picker>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="principal"
                                    label="负责人"
                                    align="center"
                                    width="200"
                                >
                                    <template slot-scope="{ row }">
                                        <el-input v-model="row.principal"  readonly>
                                            <i slot="suffix" class="el-input__icon el-icon-document-copy" @click.stop="selectEquip( $index )"></i>
                                        </el-input>
                                    </template>
                                </el-table-column>
                            </el-table>

                        </div>
                    </div> -->

                    <!-- <div id="operationRecordCon">
                        <div class="tabs-title" id="operationRecord">运行记录</div>
                        <div class="e-table">
                            <div class="top">
                                <div class="left">
                                     <el-button size="mini" class="btn-blue" @click="smmary">汇总</el-button>
                                    <el-button size="mini" class="btn-blue" @click="addPlanInfo('operationRecordList')">新增</el-button>
                                    <el-button size="mini"  @click="deletePlanList('operationRecordList')">删除</el-button>
                                </div>
                            </div>
                            <el-table
                                ref="planTable"
                                :data="formData.operationRecordList"
                                border
                                style="width: 100%"
                                @cell-mouse-enter="cellMouseEnter"
                                @cell-mouse-leave="cellMouseLeave"
                                :cell-class-name="cellClsNm"
                                @selection-change="planTableSelect($event,'operationRecordList')"
                            >
                                <el-table-column type="selection" width="55" align="center">
                                </el-table-column>
                                <el-table-column
                                    prop="epiboly"
                                    label="外包方"
                                    align="center"
                                >
                                    <template slot-scope="{ row }">
                                        <el-input v-model="row.epiboly"  readonly>
                                            <i slot="suffix" class="el-input__icon el-icon-document-copy" @click.stop="selectEquip( $index )"></i>
                                        </el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="useType"
                                    label="使用类型"
                                    width="200"
                                    align="center"
                                >
                                    <template slot-scope="{ row }">
                                        <el-select v-model="row.useType" >
                                            <el-option :value="item.value" :label="item.label" v-for="item,index in useType" :key="index" ></el-option>
                                        </el-select>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="partial"
                                    label="分部分项"
                                    width="200"
                                    align="center"
                                >
                                    <template slot-scope="{ row }">
                                        <el-input v-model="row.partial"  readonly>
                                            <i slot="suffix" class="el-input__icon el-icon-document-copy" @click.stop="selectEquip( $index )"></i>
                                        </el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="meteringWay"
                                    label="计量方式"
                                    width="200"
                                    align="center"
                                >
                                    <template slot-scope="{ row }">
                                        <el-select v-model="row.meteringWay"  >
                                            <el-option :value="item.value" :label="item.label" v-for="item,index in measurementMode" :key="index" ></el-option>
                                        </el-select>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="workHours "
                                    label="工作小时数"
                                    width="200"
                                    align="center"
                                >
                                    <template slot-scope="{ row }">
                                        <el-input v-model="row.workHours " clearable></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="meteringUnit"
                                    label="计时单位"
                                    width="200"
                                    align="center"
                                >
                                    <el-select v-model="row.meteringUnit"  >
                                            <el-option :value="item.value" :label="item.label" v-for="item,index in timeUnitList" :key="index" ></el-option>
                                    </el-select>
                                </el-table-column>
                                <el-table-column
                                    prop="useNum"
                                    label="使用数"
                                    width="200"
                                    align="center"
                                >
                                        <template slot-scope="{ row }">
                                        <el-input v-model="row.useNum" clearable></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="runStatus"
                                    label="运行状态"
                                    width="200"
                                    align="center"
                                >
                                    <template slot-scope="{ row }">
                                        <el-select v-model="row.runStatus" >
                                            <el-option :value="item.value" :label="item.label" v-for="item,index in runningState" :key="index" ></el-option>
                                        </el-select>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="jobContent"
                                    label="使用内容"
                                    width="200"
                                    align="center"
                                >
                                    <template slot-scope="{ row }">
                                        <el-input v-model="row.jobContent" clearable></el-input>
                                    </template>
                                </el-table-column>
                            </el-table>
                        </div>
                    </div> -->

                    <!-- <div id="testRecordCon">
                        <div class="tabs-title" id="testRecord">检测记录</div>
                        <div class="e-table">
                            <div class="top">
                                <div class="left">
                                    <el-button size="mini" class="btn-blue" @click="smmary">汇总</el-button>
                                    <el-button size="mini" class="btn-blue" @click="addPlanInfo('detectionRecordList')">新增</el-button>
                                    <el-button size="mini"  @click="deletePlanList('detectionRecordList')">删除</el-button>
                                </div>
                            </div>
                            <el-table
                                ref="planTable"
                                :data="formData.detectionRecordList"
                                border
                                style="width: 100%"
                                @cell-mouse-enter="cellMouseEnter"
                                @cell-mouse-leave="cellMouseLeave"
                                :cell-class-name="cellClsNm"
                                @selection-change="planTableSelect($event,'detectionRecordList')"
                            >
                                <el-table-column type="selection" width="55" align="center">
                                </el-table-column>
                                <el-table-column
                                    prop="detectionOrg"
                                    label="检测单位"
                                    align="center"
                                >
                                    <template slot-scope="{ row }">
                                        <el-input v-model="row.detectionOrg" clearable></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="detectionPrice"
                                    label="检测费用（元）"
                                    width="200"
                                    align="center"
                                >
                                    <template slot-scope="{ row }">
                                        <el-input v-model="row.detectionPrice" clearable></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="inspectTime"
                                    label="送检时间"
                                    width="250"
                                    align="center"
                                >
                                    <template slot-scope="{ row }">
                                        <el-date-picker
                                            v-model="row.inspectTime"
                                            type="date"
                                            placeholder="选择日期"
                                            value-format="yyyy-MM-dd"
                                            format="yyyy 年 MM 月 dd 日"
                                            :clearable="false"
                                        >
                                        </el-date-picker>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="completeInspectTime"
                                    label="完检时间"
                                    width="250"
                                    align="center"
                                >
                                    <template slot-scope="{ row }">
                                        <el-date-picker
                                            v-model="row.completeInspectTime"
                                            type="date"
                                            placeholder="选择日期"
                                            value-format="yyyy-MM-dd"
                                            format="yyyy 年 MM 月 dd 日"
                                            :clearable="false"
                                        >
                                        </el-date-picker>
                                    </template>
                                </el-table-column>
                            </el-table>
                        </div>
                    </div> -->

                     <div id="maintenanceRecordsCon">
                        <div class="tabs-title" id="maintenanceRecords">维修保养记录</div>
                        <div class="e-table">
                            <div class="top">
                                <div class="left">
                                    <el-button size="mini" class="btn-blue" @click="addPlanInfo('maintenanceLogList')">新增</el-button>
                                    <el-button size="mini"  @click="deletePlanList('maintenanceLogList')">删除</el-button>
                                </div>
                            </div>
                            <el-table
                                ref="planTable"
                                :data="formData.maintenanceLogList"
                                border
                                style="width: 100%"
                                @cell-mouse-enter="cellMouseEnter"
                                @cell-mouse-leave="cellMouseLeave"
                                :cell-class-name="cellClsNm"
                                @selection-change="planTableSelect($event,'maintenanceLogList')"
                            >
                                <el-table-column type="selection" width="55" align="center">
                                </el-table-column>
                                <el-table-column
                                    prop="maintenanceUnit"
                                    label="维保单位"
                                    align="center"
                                    min-width="200"
                                >
                                    <template slot-scope="{ row }">
                                        <el-input v-model="row.maintenanceUnit" clearable></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="maintenanceType"
                                    label="维保类型"
                                    width="200"
                                    align="center"
                                >
                                    <template slot-scope="{ row }">
                                        <el-select v-model="row.maintenanceType"  >
                                            <el-option :value="item.value" :label="item.label" v-for="item,index in maintenanceType" :key="index" ></el-option>
                                        </el-select>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="sendToRepairTime"
                                    label="送修/养时间"
                                    width="250"
                                    align="center"
                                >
                                    <template slot-scope="{ row }">
                                        <el-date-picker
                                            v-model="row.sendToRepairTime"
                                            type="date"
                                            placeholder="选择日期"
                                            value-format="yyyy-MM-dd"
                                            format="yyyy 年 MM 月 dd 日"
                                            :clearable="false"
                                        >
                                        </el-date-picker>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="completeRepairTime"
                                    label="完修/养时间"
                                    width="250"
                                    align="center"
                                >
                                    <template slot-scope="{ row }">
                                        <el-date-picker
                                            v-model="row.completeRepairTime"
                                            type="date"
                                            placeholder="选择日期"
                                            value-format="yyyy-MM-dd"
                                            format="yyyy 年 MM 月 dd 日"
                                            :clearable="false"
                                        >
                                        </el-date-picker>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="manpowerPrice"
                                    label="人工费（元）"
                                    width="150"
                                    align="center"
                                >
                                    <template slot-scope="{ row   }">
                                        <el-input v-model="row.manpowerPrice" clearable></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="materialsPrice"
                                    label="材料费（元）"
                                    width="150"
                                    align="center"
                                >
                                    <template slot-scope="{ row   }">
                                        <el-input v-model="row.materialsPrice" clearable></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="state"
                                    label="设备费（元）"
                                    width="150"
                                    align="center"
                                >
                                    <template slot-scope="{ row   }">
                                        <el-input v-model="row.equipmentPrice" clearable></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="equipmentPrice"
                                    label="维保费（元）"
                                    width="150"
                                    align="center"
                                >
                                    <template slot-scope="{ row }">
                                        <el-input v-model="row.maintenancePrice" clearable></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="maintenanceDetails"
                                    label="维修内容"
                                    width="150"
                                    align="center"
                                >
                                    <template slot-scope="{ row }">
                                        <el-input v-model="row.maintenanceDetails" clearable></el-input>
                                    </template>
                                </el-table-column>
                            </el-table>
                        </div>
                    </div>

                    <!-- <div id="accidentRecordCon">
                        <div class="tabs-title" id="accidentRecord">事故记录</div>
                        <div class="e-table">
                            <div class="top">
                                <div class="left">
                                    <el-button size="mini" class="btn-blue" @click="smmary">汇总</el-button>
                                    <el-button size="mini" class="btn-blue" @click="addPlanInfo('accidentRecordList')">新增</el-button>
                                    <el-button size="mini"  @click="deletePlanList('accidentRecordList')">删除</el-button>
                                </div>
                            </div>
                            <el-table
                                ref="planTable"
                                :data="formData.accidentRecordList"
                                border
                                style="width: 100%"
                                @cell-mouse-enter="cellMouseEnter"
                                @cell-mouse-leave="cellMouseLeave"
                                :cell-class-name="cellClsNm"
                                @selection-change="planTableSelect($event,'accidentRecordList')"
                            >
                                <el-table-column type="selection" width="55" align="center">
                                </el-table-column>
                                <el-table-column
                                    prop="responsible"
                                    label="事故责任人"
                                    align="center"
                                >
                                    <template slot-scope="{ row   }">
                                        <el-input v-model="row.responsible" clearable></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="accidentTime"
                                    label="事故时间"
                                    width="250"
                                    align="center"
                                >
                                    <template slot-scope="{ row }">
                                        <el-date-picker
                                            v-model="row.accidentTime"
                                            type="date"
                                            placeholder="选择日期"
                                            value-format="yyyy-MM-dd"
                                            format="yyyy 年 MM 月 dd 日"
                                            :clearable="false"
                                        >
                                        </el-date-picker>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="disposeTime"
                                    label="处理日期"
                                    width="250"
                                    align="center"
                                >
                                    <template slot-scope="{ row }">
                                        <el-date-picker
                                            v-model="row.disposeTime"
                                            type="date"
                                            placeholder="选择日期"
                                            value-format="yyyy-MM-dd"
                                            format="yyyy 年 MM 月 dd 日"
                                            :clearable="false"
                                        >
                                        </el-date-picker>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="accidentCause"
                                    label="事故原因"
                                    width="200"
                                    align="center"
                                >
                                    <template slot-scope="{ row }">
                                        <el-input v-model="row.accidentCause" clearable></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="resultOfHandling"
                                    label="处理结果"
                                    width="200"
                                    align="center"
                                >
                                    <template slot-scope="{ row }">
                                        <el-input v-model="row.resultOfHandling" clearable></el-input>
                                    </template>
                                </el-table-column>
                            </el-table>

                        </div>
                    </div> -->
                </div>
            </el-tabs>
        </div>
         <div class="buttons">
                <el-button type="primary" size="small" class="btn-blue"
                    >导入</el-button
                >
                <el-button
                    type="primary"
                    size="small"
                    class="btn-delete"
                    @click="deleteBIll"
                    >删除</el-button
                >
                <el-button
                    type="primary"
                    size="small"
                    class="btn-blue"
                    @click="submit"
                    >保存并提交</el-button
                >
                <el-button
                    type="primary"
                    size="small"
                    class="btn-blue"
                    @click="preserve"
                    >保存</el-button
                >
                <el-button size="small" @click="handleClose">取消</el-button>
            </div>
        <div id="seat" :style="{height: seatHeight + 'px'}"></div>
    </div>
</template>

<script>
import { mapState } from 'vuex'
import SelectEquip from '@/pages/equipment/equipPlan/configPlan/configPlanDialog/selectEquip.vue'
import $ from 'jquery'
import request from '@/api/equip/equipInit.js'
import { formatDate } from '@/utils/common.js'
import '@/utils/jquery.scrollTo.min'
export default {
    data () {
        return {
            // dialogVisible: false,
            // fullscreen: false,
            tabsName: 'baseInfo',
            screenWidth: 0,
            screenHeight: 0,
            lastConHeight: 0,
            clickTabFlag: false, // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            form: {
                name: '',
                region: '',
                date1: '',
                date2: '',
                delivery: false,
                type: [],
                resource: '',
                desc: ''
            },
            selectEquipVisible: false,
            tableData: [],
            planTableData: [{ 'd': 123, c: '' }],
            value: '',
            textarea: '',
            formData: {
                //基础信息
                'facilityInitialize': {
                    'acceptanceCheck': '',
                    'accumulativeDepreciation': 0,
                    'checkDate': '',
                    'checkPlace': '',
                    'cumulativeNum': 0,
                    'equipmentAttribute': 0,
                    'equipmentCompletely': 0,
                    'equipmentCondition': 0,
                    'equipmentName': '',
                    'equipmentNo': '',
                    'equipmentOriginal': 0,
                    'equipmentStatus': 0,
                    'equipmentType': '',
                    'equipmentTypeId': '',
                    'facilityInitializeId': '',
                    'manufacturer': '',
                    'meteringUnit': 0,
                    'operation': '',
                    'operationId': '',
                    'orgId': '',
                    'orgName': '',
                    'originalNum': '',
                    'productionNum': '',
                    'productionTime': '',
                    'purchaseTime': '',
                    'specificationModel': '',
                    'stipulateYear': 0,
                    'useOrg': '',
                    'useOrgId': '',
                    'useYear': 0,
                    'vehicleNum': ''
                },
            },
            billid: '',
            planSelect: [], //固定资产盘点明细选择项
            workIndex: 0,
            typeList: [ //申请类型
                { value: 0, label: '全部' },
                { value: 1, label: '报废' },
                { value: 2, label: '处置' },
            ],
            processModeList: [ //处置方式
                { value: 0, label: '自行处置' },
                { value: 1, label: '公开转让' },
                { value: 2, label: '公开招标' },
            ],
            scrapTypeList: [ //报废类型
                { value: true, label: '正常报废' },
                { value: false, label: '异常报废' },
            ],
            checkResultsList: [ //清查结果
                { value: 0, label: '账物相符' },
                { value: 1, label: '有账无物' },
                { value: 2, label: '有物无账' },
            ],
            rules: {
                specificationModel: [{ required: true, message: '规格型号不能为空', trigger: 'blur' }],
                checkExplain: [{ required: true, message: '清查说明不能为空', trigger: 'blur' }],
            },
        }
    },
    computed: {
        ...mapState({
            userInfo: state => state.userInfo,
            currencyForm: state => state.contract.ctClassify.currencyForm, //币种
            equipStatus: state => state.equip.equipData.equipStatus, //设备状态
            timeUnitList: state => state.equip.equipData.timeUnitList, //计时单位
            useType: state => state.equip.equipData.useType, //计时单位
            measurementMode: state => state.equip.equipData.measurementMode, //计量方式
            runningState: state => state.equip.equipData.runningState, //运行状态
            maintenanceType: state => state.equip.equipData.maintenanceType, //维保类型
            equipCondition: state => state.equip.equipData.equipCondition, //设备状况
        }),
        statusLable () {
            return param=> {
                const state =  this.$store.state.equip.equipData.state
                const obj = state.find(x=>x.value === param)
                return obj.label
            }
        },
        // 填补底部空白，以使高度够滚动
        seatHeight () {
            return this.screenHeight - 72 - this.lastConHeight
        }
    },
    components: {
        SelectEquip
    },
    created () {
        this.billid = this.$route.query.billid
        this.userId = localStorage.getItem('userId')
        this.getDicValue()
        this.getInfo()
    },
    mounted () {

        // 获取最后一个内容区域的高度，计算底部空白
        this.getLastConHeight()

        // 保存所有tabName
        // const arr = ['baseInfo', 'equipInitparam', 'transformationRegist', 'operationRecord', 'testRecord', 'maintenanceRecords', 'accidentRecord']
        const arr = ['baseInfo', 'maintenanceRecords']
        let $idsTop = []
        window.addEventListener('scroll', () => {
            // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            if (this.clickTabFlag) {
                return
            }

            if (!$idsTop[$idsTop.length - 1]) {
                $idsTop = arr.map(item => {
                    console.log('item', item)
                    const itemTop = document.getElementById(item).offsetTop
                    return itemTop
                })
            }
            const scrollTop = document.documentElement.scrollTop || document.body.scrollTop
            // 倒序查找
            let curLocal = 0
            for (let len = $idsTop.length, i = len - 1; i >= 0; i--) {
                let item = $idsTop[i]
                if ((scrollTop + 1) >= item) {
                    curLocal = i
                    break
                }
            }
            // 设置对应tabName
            this.tabsName = arr[curLocal]
        })

        this.screenWidth = document.documentElement.clientWidth
        this.screenHeight = document.documentElement.clientHeight
        window.addEventListener('resize', () => {
            this.screenWidth = document.documentElement.clientWidth
            this.screenHeight = document.documentElement.clientHeight
            $idsTop = arr.map(item => {
                const itemTop = document.getElementById(item).offsetTop
                return itemTop
            })
        })

    },
    methods: {
        //获取当前使用的字典
        getDicValue () {
            this.$store.dispatch('equip/setTimeUnitList')//更新计时单位
            this.$store.dispatch('equip/setUseType')//更新使用类型
            this.$store.dispatch('equip/setMeasurementMode')//更新计量方式
            this.$store.dispatch('equip/setRunningState')//更新运行状态
            this.$store.dispatch('equip/setMaintenanceType')//更新维保类型
            this.$store.dispatch('equip/setEquipStatus')//更新设备状态
        },
        selectEquip ( index) {
            this.workIndex = index
            this.selectEquipVisible = true
        },
        getInfo () {
            const params = {
                id: this.billid,
            }
            request.equipInitBaseInfo(params).then(res=>{
                this.formData = res
                this.getPlanList()
            })
        },
        getPlanList () {
            const params = {
                id: this.billid,
            }
            //获取设备参数
            request.equipInitparam(params).then(res=>{
                this.formData.facilityParameterList = res.facilityParameterList
            })
            //获取技改登记
            request.transformationRegist(params).then(res=>{
                this.formData.technicallyRegistrations = res.technicallyRegistrations
            })
            //获取运行记录
            request.operationRecord(params).then(res=>{
                this.formData.operationRecordList = res.operationRecordList
            })
            //获取检测记录
            request.testRecord(params).then(res=>{
                this.formData.detectionRecordList = res.detectionRecordList
            })
            //获取维修保养记录
            request.maintenanceRecords(params).then(res=>{
                this.formData.maintenanceLogList = res.maintenanceLogList
            })
            //获取事故记录
            request.accidentRecord(params).then(res=>{
                this.formData.accidentRecordList = res.accidentRecordList
            })
        },
        getNowDate () {
            this.$set(
                this.formData,
                'applyTime',
                new Date()
                    .toLocaleDateString()
                    .replace(new RegExp('/', 'g'), '-')
            )
        },
        handleFullScreen () {
            this.fullscreen = !this.fullscreen
        },
        cellClsNm ({ column }) {
            if (column.label === '') {
                return 'fixed-left'
            }
        },
        cellMouseEnter (row) {
            this.MouseEnterId = row.id
        },
        cellMouseLeave () {
            this.MouseEnterId = 0
        },
        // 获取最后一个内容区域的高度，计算底部空白
        getLastConHeight () {
            let si = setInterval(() => {
                // 因为dom异步加载，通过轮询找到渲染后的dom，获取高度
                if (document.getElementById('recodesCon')) {
                    const lastConHeight = document.getElementById('recodesCon').offsetHeight
                    console.log('lastConHeight: ', lastConHeight)
                    this.lastConHeight = lastConHeight
                    clearInterval(si)
                    si = null
                }
            }, 100)
        },
        onChangeTab (e) {
            console.log('clickTabFlag: ', this.clickTabFlag)
            $.scrollTo(`#${e.name}`, 500)
            // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            this.clickTabFlag = true
            // 动画结束后，恢复状态
            setTimeout(() => {
                this.clickTabFlag = false
            }, 600)
        },
        //明细
        addPlanInfo (field) {
            const arr = this.formData[field] ? this.formData[field] : []
            switch(field)
            {
            case 'accidentRecordList':
                {
                    const obj = {
                        'accident': '',
                        'accidentCause': '',
                        'accidentRecordId': '',
                        'accidentTime': '',
                        'disposeTime': '',
                        'facilityInitializeId': '',
                        'resultOfHandling': ''
                    }
                    let date  = formatDate(new Date(), 'yyyy-MM-dd')
                    obj.accidentTime = date
                    obj.disposeTime = date
                    arr.push(obj)
                }
                break
            case 'detectionRecordList':
                {
                    const obj = {
                        'completeInspectTime': '',
                        'detectionOrg': '',
                        'detectionOrgId': '',
                        'detectionPrice': 0,
                        'detectionRecordId': '',
                        'facilityInitializeId': '',
                        'inspectTime': '',
                        'inspector': '',
                        'inspectorId': ''
                    }
                    let date  = formatDate(new Date(), 'yyyy-MM-dd')
                    obj.inspectTime = date
                    obj.completeInspectTime = date
                    arr.push(obj)
                }
                break
            case 'facilityParameterList':
                {
                    const obj =  {
                        'facilityInitializeId': '',
                        'facilityParameterId': '',
                        'parameterName': '',
                        'parameterValue': ''
                    }
                    arr.push(obj)
                }
                break
            case 'maintenanceLogList':
                {
                    const obj =  {
                        'completeRepairTime': '',
                        'equipmentPrice': 0,
                        'facilityInitializeId': '',
                        'maintenanceDetails': '',
                        'maintenanceLogId': '',
                        'maintenancePrice': 0,
                        'maintenanceType': 0,
                        'maintenanceUnit': '',
                        'manpowerPrice': 0,
                        'materialsPrice': 0,
                        'sendToRepairTime': ''
                    }
                    let date  = formatDate(new Date(), 'yyyy-MM-dd')
                    obj.sendToRepairTime = date
                    obj.completeRepairTime = date
                    arr.push(obj)
                }
                break
            case 'operationRecordList':
                {
                    const obj =  {
                        'contractName': '',
                        'endTime': '',
                        'epiboly': '',
                        'epibolyId': '',
                        'facilityInitializeId': '',
                        'jobContent': '',
                        'meteringUnit': 0,
                        'meteringWay': 0,
                        'operationRecordId': '',
                        'partial': '',
                        'partialId': '',
                        'runStatus': 0,
                        'statrTime': '',
                        'useNum': 0,
                        'useType': 0
                    }
                    arr.push(obj)
                }
                break
            case 'technicallyRegistrations':
                {
                    const obj =  {
                        'artificialCost': 0,
                        'equipmentPrice': 0,
                        'facilityInitializeId': '',
                        'materialPrice': 0,
                        'principal': '',
                        'principalId': '',
                        'recordDate': '',
                        'technicallyIncreasePrice': 0,
                        'technicallyOrg': '',
                        'technicallyPrice': 0,
                        'technicallyRegistrationId': ''
                    }
                    let date  = formatDate(new Date(), 'yyyy-MM-dd')
                    obj.recordDate = date
                    arr.push(obj)
                }
                break
            }
            this.$set(this.formData, field,  arr)
        },
        //选择设备确认
        selectConfirm (data) {
            if(!data) return false
            const arr = this.formData.fixedAssetsCheckDtlList ? this.formData.fixedAssetsCheckDtlList : []
            data.forEach(x=>{
                const obj = {
                    'billNo': '',
                    'buyTime': '',
                    'checkExplain': '',
                    'checkResults': 0,
                    'depositSite': '',
                    'depositSiteId': '',
                    'equipmentName': '',
                    'equipmentNo': '',
                    'fixedAssetsCheckDtlId': '',
                    'fixedAssetsCheckId': '',
                    'isCollect': '',
                    'originalPrice': 0,
                    'specificationModel': '',
                    ...x,
                    'state': '0',
                }
                let date  = formatDate(new Date(), 'yyyy-MM-dd')
                obj.buyTime = date
                arr.push(obj)
            })
            this.$set(this.formData, 'fixedAssetsCheckDtlList',  arr)
            console.log('fixedAssetsCheckDtlList', this.formData.fixedAssetsCheckDtlList)
            console.log('fixedAssetsCheckDtlList', this.formData.fixedAssetsCheckDtlList)
            this.selectEquipVisible = false
        },
        //保存
        preserve () {
            request.equipInitUpdate(this.formData).then(()=>{
                this.clientPop('suc', '保存成功', ()=>{ this.$router.push('/equipInitList') })
            })
        },
        //提交
        submit () {
            request.equipInitUpdate(this.formData).then(()=>{
                request.equipInitCommit({ facilityInitializeIdList: this.billid }).then(()=>{
                    this.$message.success('提交成功')
                    this.$router.push('/equipInitList')
                })
            })

        },
        //删除
        deleteBIll () {
            this.clientPop('err', '确定要删除吗？删除的数据可以在【回收站】还原或彻底删除。', ()=>{
                request.equipInitDelete({ facilityInitializeIdList: this.billid }).then(()=>{
                    this.clientPop('suc', '删除成功', ()=>{ this.$router.push('/equipInitList') })
                })
            })
        },
        //作废
        nullifyeBIll () {
            request.assetsInventoryNullify({ facilityInitializeIdList: this.billid }).then(()=>{
                this.$message.success('作废成功')
                this.$router.push('/assetsInventoryList')
            })
        },
        //删除固定资产盘点明细列表
        deletePlanList (feild) {
            this['planSelect' + feild].forEach(row=>{
                const index = this.formData[feild].findIndex(item=>{
                    return item === row
                })
                this.formData[feild].splice(index, 1)
            })

        },
        //获取固定资产盘点明细表格的选择项
        planTableSelect (selection, feild) {
            this['planSelect' + feild] = selection
        },
        //取消
        handleClose () {
            this.$router.go(-1)
        },
        // 获取地址对应中文
        getAddrLabel (val) {
            console.log('getAddrLabel: ', val)
            this.formData.fixedAssetsCheck.acceptanceSiteList = val
        },
        //汇总
        smmary () {
            const params = {
                orgId: this.userInfo.orgInfo.orgId
            }
            request.assetsInventorSmmary(params).then(res=>{
                console.log('res', res)
            })
        },
    }
}
</script>

<style lang="scss" scoped>
.form {
    margin-top: 10px;
}

.e-table {
    background: #fff;

    /* .top {
    .left {
      padding: 20px;
      padding-top: 0px;
    }
  } */
}

.upload {
    margin: 20px auto;
    display: flex;
    justify-content: center;
    text-align: center;
}

.upload-demo {
    display: flex;
    justify-content: center;
    align-items: center;
}
</style>
